package model

import (
	"gorm.io/gorm"
	"time"
)

type Goods struct {
	Id        uint           `gorm:"column:id;type:bigint(20) UNSIGNED;primaryKey;not null;" json:"id"`
	UserId    uint           `gorm:"column:user_id;type:bigint(20) UNSIGNED;comment:用户ID;not null;default:0;" json:"user_id"`    // 用户ID
	Title     string         `gorm:"column:title;type:varchar(50);comment:商品标题;not null;" json:"title"`                          // 商品标题
	Price     float64        `gorm:"column:price;type:decimal(10, 2) UNSIGNED;comment:商品价格;not null;default:0.00;" json:"price"` // 商品价格
	Stock     uint32         `gorm:"column:stock;type:int(11) UNSIGNED;comment:商品库存;not null;default:0;" json:"stock"`           // 商品库存
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (g *Goods) TableName() string {
	return "goods"
}
